package com.soul.server.controller;

import com.soul.model.mongo.UserLike;
import com.soul.server.server.BaiduService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author mdoya
 * @version 1.0
 * @description: 用户上报地理位置
 */
@Slf4j
@RestController
@RequestMapping("/baidu")
public class BaiduController {

    @Autowired
    private BaiduService baiduService;

    /**
     *  用户上报地理位置
     * @param params 接受前端参数map对象
     * @return null
     */
    @RequestMapping(path = "/location",method = RequestMethod.POST)
    public ResponseEntity reportLocation(@RequestBody Map<String,Object> params){
        Double latitude = (Double)params.get("latitude");
        Double longitude = (Double)params.get("longitude");
        String addrStr = String.valueOf(params.get("addrStr"));
        baiduService.reportLocation(longitude,latitude,addrStr);
        return ResponseEntity.ok(null);
    }
}
